/*
 * @Author: szx
 * @Date: 2022-03-23 15:26:02
 * @LastEditTime: 2022-03-23 15:45:33
 * @Description:
 * @FilePath: \leetcode\700-799\746\746_2.js
 */
/**
 * @param {number[]} cost
 * @return {number}
 */
var minCostClimbingStairs = function (cost) {
    const n = cost.length;
    const dp = new Array(n).fill(0);
    dp[0] = cost[0];
    dp[1] = cost[1];
    for (let i = 2; i < n; i++) {
        dp[i] = Math.min(dp[i - 2], dp[i - 1]) + cost[i];
    }
    return Math.min(dp[n - 2], dp[n - 1]);
};
console.log(minCostClimbingStairs([10, 15, 20]));
console.log(minCostClimbingStairs([1, 100, 1, 1, 1, 100, 1, 1, 100, 1]));
